<template>
  <ych-modal
    :fullscreen="false"
    :title="title"
    :visible="visible"
    @ok="handleOk"
    @cancel="handleCancel"
    :okText="okText"
    :cancelText="$t('m.common.button.close')">

    <a-form :labelCol="labelCol" :wrapperCol="wrapperCol">
      <a-row>
        <a-col :span="12">
          <a-form-item :label="$t('m.eform.appmarket.entity.appName')">
            {{record.name}}
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item :label="$t('m.eform.appmarket.entity.appCode')">
            {{record.code}}
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item :label="$t('m.eform.appmarket.entity.appVersion')">
            {{record.version}}
          </a-form-item>
        </a-col>
        <a-col :span="12">
          <a-form-item :label="$t('m.eform.appmarket.entity.createTime')">
            {{record.create_time}}
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
    <p>
      {{record.function_desc}}
    </p>
  </ych-modal>
</template>

<script>

  export default {
    name: 'MarketInfoDialog',
    props: {
      record: {
        type: Object,
        default: () => {
        }
      },
      currentCodeList: {
        type: Array,
        default: () => []
      }
    },
    computed: {
      okText () {
        if (this.currentCodeList.indexOf(this.record.code) == -1) {
          return this.$t('m.eform.appmarket.other.install')
        } else {
          return this.$t('m.eform.appmarket.other.update')
        }
      }
    },
    data () {
      return {
        title: this.$t('m.common.title.detail'),
        visible: false,
        labelCol: {
          xs: { span: 24 },
          sm: { span: 6 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
      }
    },
    methods: {
      handleOk () {
        this.$emit('ok')
        this.handleCancel()
      },
      handleCancel () {
        this.visible = false
      },
    }
  }
</script>
